package com.kfm.spring.model;

import lombok.Data;
import org.hibernate.validator.constraints.Range;

import javax.validation.constraints.*;
import java.util.List;

@Data
public class User implements java.io.Serializable {

    @NotNull(message = "【id】不能为空", groups = {Update.class})
    private Integer id;

    @Size(min = 6,max = 12, message = "【用户名】长度必须在6-12之间", groups = {Update.class, Add.class})
    private String username;


    @Size(min = 6,max = 18, message = "【密码】长度必须在6-18之间", groups = {Update.class, Add.class})
    @Pattern(regexp = "^[a-zA-Z]\\w{5,17}$", message = "【密码】必须以字母开头，长度在6-18之间，只能包含字符、数字和下划线", groups = {Update.class, Add.class})
    private String password;

//    @Max(value = 100, message = "【年龄】不能大于100", groups = {Update.class, Add.class})
//    @Min(value = 18, message = "【年龄】不能小于18", groups = {Update.class, Add.class})
    @Range(min = 18, max = 100, message = "【年龄】必须在18-100之间", groups = {Update.class, Add.class})
    private Integer age;

    private List<Account> accounts;


    public static interface Update{}

    public static interface Add{}
}


